<?php

namespace WoXuanWang\Video\Models;

use Eloquent as Model;
use EstGroupe\Taggable\Taggable;

/**
 * Class Compilation
 * @package WoXuanWang\Compilation\Models
 * @version April 6, 2017, 4:45 pm CST
 */
class Compilation extends Model
{
    use Taggable;

    public $table = 'compilations';


    public $fillable = [
        'title',
        'category_id',
        'description',
        'cover_id',
        'visible_purview',
        'released_at',
        'funding_id',
        'year',
        'region'
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'title'           => 'string',
        'category_id'     => 'integer',
        'description'     => 'string',
        'cover_id'        => 'integer',
        'visible_purview' => 'integer',
        'released_at'     => 'date',
        'funding_id'      => 'integer',
        'region'          => 'string'
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'title' => 'required'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     **/
    public function videoCategory()
    {
        return $this->belongsTo(\WoXuanWang\Video\Models\VideoCategory::class, 'category_id', 'id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function funding()
    {
        return $this->hasOne(\WoXuanWang\Funding\Models\Funding::class, 'funding_id', 'id');
    }

    /**
     * TODO 参与制作的用户
     */
    public function participants()
    {

    }
}
